package weifei.wx.community.service;


import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import weifei.wx.community.entity.dto.TieDTO;
import weifei.wx.community.mapper.TieMapper;

@Service
public class TieService
{
    @Autowired
    private UserService userService;

    @Autowired
    private TieMapper tieMapper;


    public TieDTO getTieByID(Long id)
    {
        QueryWrapper queryWrapper = QueryWrapper.create()
                .select()
                .where("id = ?", id);
        var tie = this.tieMapper.selectOneByQuery(queryWrapper);
        var userDTO = this.userService.getUserByID(tie.getUserId());
        return new TieDTO(userDTO, tie);
    }
}


